<template>
	<view class="trip">
		<view class="ey same">
			<text class="car">车牌号</text>
			<view class="put">
				<up-input placeholder="请输入车牌号" border="surround" v-model="carnum"></up-input>
			</view>
		</view>
		
		<view class="ey same">
			<text class="car">加油量</text>
			<view class="put">
			<up-input placeholder="请输入加油量" border="surround" v-model="gas"></up-input>
		    </view>
		</view>
		
		<view class="ey same">
			<text class="car">金额</text>
			<view class="put">
			<up-input placeholder="请输入金额" border="surround" v-model="money"></up-input>
		    </view>
		</view>
		
		<view class="ey same">
			<text class="car">行驶日期</text>
			<view class="put">
			<up-input placeholder="请输入行驶日期" border="surround" v-model="date"></up-input>
		    </view>
		</view>
		
		<view class="ey same">
			<text class="car">行驶里层</text>
			<view class="put">
			<up-input placeholder="请输入行驶里层" border="surround" v-model="travel"></up-input>
		    </view>
		</view>
		
		<up-button type="primary" text="添加" @click="gettripdate"></up-button>
	
	</view>
</template>

<script setup>
import {gettrip} from '@/api/parkApi.js'
import { ref } from 'vue'

const carnum = ref()  //车牌号
const gas =ref()      //油
const money=ref()     //金额
const date=ref()      //日期
const travel=ref()    //里层

const gettripdate=async()=>{
	
	if(money.value==null || gas.value==null ||carnum.value==null || date.value==null || travel.value==null){
		uni.showToast({
			title:'内容不得为空',
			icon:'error'
		})
		return;
	}
	
    let res = await gettrip({
	   header: {
	   	'Authorization': uni.getStorageSync('token')
	   },
	   data:{
		   amount:money.value,
		   gasFilling:gas.value,
		   plateNo:carnum.value,
		   travelDate:date.value,
		   travelDistance:travel.value
	   }
    })
	if(res.code==200){
		uni.showToast({
			title:'添加成功',
		})
		uni.navigateTo({
			url:'/pages/park/cart/consumption/consumption'
		})
	}else{
		//静态数据
		uni.showToast({
			title:'添加成功',
		})
		uni.navigateTo({
			url:'/pages/park/cart/consumption/consumption'
		})
	}
}



</script>
<style lang="scss">
.trip{
   padding:8px 14px;
   
	.ey{
	  display: flex;
	  align-items: center;
	  
	  .car{
		  flex:1;
		  font-size: 18px;
		  font-weight: 700;
		  text-align-last: justify;
		  margin-right:14px;
		  
	  }
	  .put{
		  flex: 3;
	  }
	}
	.same{ 
		margin: 10px 0px;
	}
	
	::v-deep .u-button{
		margin: 10px 0px;
	}
}
</style>
